﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entity;
using Business.IManager;
using DataAccess.IService;
using DataAccess.Service;
using System.Data;

namespace Business.Manager
{
    public class PaymentProjectManager:IPaymentProjectManager
    {
        IPaymentProjectService paymentProjectService = new PaymentProjectService();
        List<string> studentIds = new List<string>();
        IPaymentItemManager itemManager = new PaymentItemManager();
        IAcademyManager accademyManager = new AcademyManager();

        public void generateProject(PaymentProject project)
        {
            int newId = paymentProjectService.insertProject(project);
            project.PaymentProjectId = newId;
            for (int i = 0; i < project.ProjectDetailList.Count;i++ )
            {
                project.ProjectDetailList[i].PaymentProjectId = newId;
            }
            itemManager.generateProjectDetail(project.ProjectDetailList);
            /*studentIds=accademyManager.getStudentIds(project);
            geneStudentProject(project, studentIds);
            List<String> stuProjectIds = getStuProjectId(project, studentIds);
            itemManager.geneStudentPaymentDetail(project, stuProjectIds);*/
        }

        public List<String> getStuProjectId(PaymentProject project, List<string> studentIds)
        {
            return paymentProjectService.selectStuProjectIds(project, studentIds);
        }
        public int getMaxProjectId()
        {
           return paymentProjectService.selectMaxProjectId();
        }
        public DataSet getPaymentType()
        {
            return paymentProjectService.selectPaymentProjectType();
        }
        public void geneStudentProject(PaymentProject project, List<String> studentIds)
        {
            paymentProjectService.insertStudentProject(project, studentIds);
        }

        public DataSet getStudentPaymentProject(string stuId)
        {
            return paymentProjectService.getStudentPaymentProjectDS(stuId);
        }

        public DataSet getPaymenmtProdectList(int year, int operatorId)
        {
            string yearValue,operatorIdValue;
            if (year==0)
            {
                yearValue = "%%";
            }else{
                yearValue = year.ToString();
            }
            if (operatorId ==0)
            {
                operatorIdValue = "%%";
            } 
            else
            {
                operatorIdValue = operatorId.ToString();
            }

            return paymentProjectService.getPaymenmtProdectList(yearValue, operatorIdValue);
        }
    }
   
}
